package com.sinosoft.dsp.component.bpm.viewbean.activity.part;

import javax.xml.namespace.QName;

import org.jbpm.xsdobject.Process;

import com.sinosoft.dsp.component.bpm.util.ProcessParse;
import com.sinosoft.dsp.component.bpm.viewbean.BpmJpdlDefineViewBean;
import com.sinosoft.dsp.component.bpm.viewbean.activity.IBpmActivityPartEditViewBean;
import com.sinosoft.dsp.system.core.exception.SinoException;
import com.sinosoft.dsp.system.to.IGenericTO;
import com.sinosoft.dsp.system.to.attribute.Attribute;
import com.sinosoft.dsp.system.to.helper.ToHelper;
import com.sinosoft.dsp.system.utils.Const;

public class BpmActivityTaskBaseViewBean extends BpmActivityCommonBaseViewBean
		implements IBpmActivityPartEditViewBean {

	// 活动处理完成后提示
	public static final String FIELD_COMPLATE_TIP = "completeTip";

	// 是否自动打开帮助
	public static final String FIELD_AUTO_HELP = "autoHelp";

	@Override
	public void init(IGenericTO tos) throws SinoException {
		super.init(tos);
		this.addField(FIELD_AUTO_HELP, false);

		// 活动对象
		Attribute<?> name = ToHelper.getContentAttriubteByName(tos,
				BPM_NODE_NAME);
		String nameStr = name.convertToString();

		BpmJpdlDefineViewBean pvb = (BpmJpdlDefineViewBean) this.getParent()
				.getParent();
		org.jbpm.xsdobject.Process process = pvb.getProcess();
		Process.Task obj = (Process.Task) ProcessParse.getActivity(process,
				nameStr);

		String completeTip = obj.getOtherAttributes().get(
				QName.valueOf(FIELD_COMPLATE_TIP));
		this.addField(FIELD_COMPLATE_TIP, Const.NVL(completeTip, ""));

		String autoHelp = obj.getOtherAttributes().get(
				QName.valueOf(FIELD_AUTO_HELP));
		this.addField(FIELD_AUTO_HELP, Boolean.valueOf(Const.NVL(autoHelp,
				"false")));
	}
}
